program ifaninh(input,output);
 var m,n,s:integer;

 begin
  read(m,n);
  s:=0;
  if m<=n
  then begin
         if n<=s
         then begin
                  s:=s+2;
                  n:=m+1-3
              end
         else begin
                  s:=s-m;
                  n:=2*m
              end;
         write(m,s);
         m:=m+1-s*9
       end
  else begin
         if n<=s
         then begin
                  s:=s+2;
                  n:=m+1-3
              end
         else begin
                  s:=s-m;
                  n:=2*m
              end
       end
end.
